package br.com.ilha.bo;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import br.com.ilha.bean.Municipio;
import br.com.ilha.dao.MunicipioDao;

public class MunicipioBO {

	private MunicipioDao dao;
	
	public MunicipioBO() {
		dao = new MunicipioDao();
	}
	
	public void populaMunicipios() {
		
		List<Municipio> municipios = new ArrayList<Municipio>();

		File file = null;
		FileReader fr = null;
		BufferedReader buffer = null;
		String linha = null;
		
		try {
			
			file = new File("../estados&cidades.csv");
			fr = new FileReader(file);
			buffer = new BufferedReader(fr);
			
			linha = buffer.readLine();
			while(linha != null){
				System.out.println(linha.toString());
				linha = buffer.readLine();
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
		MunicipioDao municipioDao = new MunicipioDao();
		municipioDao.adiciona(municipios);
		
	}
	
}
